package com.googlecode.perfectable.persistable;

import java.util.Collection;
import java.util.LinkedList;

public class Finalizer {
	public interface Listener {
		void performFinalization(Object finalized);
	}

	private static final Collection<Listener> LISTENERS = new LinkedList<>();

	public static void dispose(Object disposable) {
		for(Listener listener : LISTENERS) {
			listener.performFinalization(disposable);
		}
	}

	public static void register(Listener listener) {
		LISTENERS.add(listener);
	}
}
